package com.ruoyi.bigbase.mapper;

import java.util.List;
import com.ruoyi.bigbase.domain.Customer;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 客户信息Mapper接口
 * 
 * @author bigbase
 * @date 2025-05-09
 */
public interface CustomerMapper
{
    /**
     * 查询客户信息
     * 
     * @param id 客户信息主键
     * @return 客户信息
     */
    public Customer selectCustomerById(Integer id);

    /**
     * 查询客户信息列表
     * 
     * @param customer 客户信息
     * @return 客户信息集合
     */
    public List<Customer> selectCustomerList(Customer customer);

    /**
     * 新增客户信息
     * 
     * @param customer 客户信息
     * @return 结果
     */
    public int insertCustomer(Customer customer);

    /**
     * 修改客户信息
     * 
     * @param customer 客户信息
     * @return 结果
     */
    public int updateCustomer(Customer customer);

    /**
     * 删除客户信息
     * 
     * @param id 客户信息主键
     * @return 结果
     */
    public int deleteCustomerById(Integer id);

    /**
     * 批量删除客户信息
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteCustomerByIds(Integer[] ids);

    @Update("update `user` set default_addr_id = #{addressId} where id = #{id}")
    public int updateAddress(@Param("id") Integer id,@Param("addressId") Integer addressId);

    @Select("select id from `user` where user_name = #{userName}")
    public Integer getIdByUsername(String userName);

    @Select("select * from `user` where user_name = #{userName}")
    public Customer isUsernameExist(String userName);

    @Select("select * from `user` where phone = #{phone}")
    public Customer isPhoneExist(String phone);

    @Select("select * from `user` where email = #{email}")
    public Customer isEmailExist(String email);

    @Update("update `user` set status = #{status} where id = #{id}")
    public int updateCustomerStatus(@Param("id") Integer id,@Param("status") Integer status);
}
